package oop4;

/**
 * @author oldliu
 * @since 1.0
 */
public class Dog extends Pet {
    private String srain;//类别
    public Dog(String type){
        this.srain=type;
    }
    public Dog(String n,int h,int l,String sex,String type){
        //super();
        super(n,h,l,sex);
        this.srain=type;
    }

    @Override//重写的标志
    public final void print() {
        System.out.println("这是一只狗，类别是"+srain);
        super.print();
//        System.out.println("名字是"+super.name);
//        System.out.println("性别是"+super.getSex());
    }
    public void catchMouse(String mouse){
        System.out.println(super.name+"抓住了老鼠"+mouse);
        //System.out.println(super.getName()+"抓住了老鼠"+mouse);
    }

    public String getSrain() {
        return srain;
    }

    public void setSrain(String brain) {
        this.srain = brain;
    }

    @Override
    public String toString() {
        return "这是一只宠物狗，名字"+this.getName()+",性别"+this.getSex()+"，健康值是"+this.getHealth()+",可爱程度是"+this.getLove()+",类别是"+this.srain;
    }

    //比较两只狗，规定只要名字是一样，认为他们相同
    //改进后的equals
    @Override
    public boolean equals(Object obj) {
        if(this==obj)
            return true;
        if(obj instanceof Dog){
            Dog d=(Dog)obj;
            return  this.name.equals(d.name) ;
        }
        return false;
       //&& this.srain.equals(d.srain);
    }
}
